#include "filewriteimpl.h"

CFileWriteImpl::CFileWriteImpl(void)
{
	loadFileInstance(&m_FileOpt);
	m_hFile = FILE_INVALID;
}

CFileWriteImpl::~CFileWriteImpl(void)
{
}
//////////////////////////////////////////////////////////////////////////
std_method_impl CFileWriteImpl::LoadFile(const TCHAR* pszLoadFile,
										 unsigned long ulwDesiredAccess,
										 unsigned long ulShareMode,
										 unsigned long ulCreationDisposition,
										 unsigned long ulFlagsAndAttributes)
{
	HRESULT		hr	=	S_OK;

	m_hFile = m_FileOpt.Open(pszLoadFile, O_RDWR | O_CREAT, 0644);

	return hr;
}
std_method_impl CFileWriteImpl::CloseFile()
{
	HRESULT		hr	=	S_OK;

	if (m_hFile != FILE_INVALID)
	{
		m_FileOpt.Close(m_hFile);
		m_hFile = FILE_INVALID;
	}

	return hr;
}
std_method_type_impl(os_int64) CFileWriteImpl::GetFileSize()
{
	return m_FileOpt.fSize(m_hFile);
}

std_method_impl CFileWriteImpl::WriteBuffer(char* szBuffer, os_int64 ulWriteSize)
{
	HRESULT		hr	=	S_OK;


	size_t size = ulWriteSize & UINT32_MAX;

	if (!m_FileOpt.Write(m_hFile, szBuffer, size) )
	{
		return S_OK;
	}
	iosprintf("write file error")
	return E_FAIL;
}
std_method_impl CFileWriteImpl::AsynWriteBuffer(char* szBuffer, os_int64 ulWriteSize)
{
	HRESULT		hr	=	S_OK;

	return hr;
}

